﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Snowdreamist.Collection;

namespace SNSpirit.Domain.Forum
{
    /// <summary>
    /// Region
    /// 版块
    /// </summary>
    public class Region : LazyDomainEntity
    {
        public Region(ForumService service)
            : base(new LoadAction<LazyDomainEntity>(o =>
                {
                    service.UpdateCore(o as Region);
                }), true)
        {
            if (service == null)
                throw new ArgumentNullException("service");
            this.Service = service;
        }

        /// <summary>
        /// Forumservice this entity bound to
        /// </summary>
        public ForumService Service { get; private set; }

        #region Name

        private object _Name;

        /// <summary>
        /// Name
        /// </summary>
        public object Name
        {
            get { return this._Name; }
            set
            {
                if (this._Name != value)
                {
                    this._Name = value;
                    this.OnPropertyChanged("Name");
                }
            }
        }

        #endregion Name

        #region Description

        private object _Description;

        /// <summary>
        /// Description
        /// </summary>
        public object Description
        {
            get { return this._Description; }
            set
            {
                if (this._Description != value)
                {
                    this._Description = value;
                    this.OnPropertyChanged("Description");
                }
            }
        }

        #endregion Description

        /// <summary>
        /// Sub regions
        /// </summary>
        public ConcurrentCollection<Region> SubRegions { get; private set; }

        /// <summary>
        /// Threads
        /// </summary>
        public ConcurrentCollection<Thread> Threads { get; private set; }

        public virtual void Update()
        {
            this.Load();
        }

        public virtual void UpdateAsync()
        {
            this.LoadAsync();
        }
    }
}